//
//  ShareViewController.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/6/7.
//

#import "ShareViewController.h"
#import "CommonUtil.h"
#import "ZPScrollerScaleView.h"
#import "CardView.h"

@interface ShareViewController ()
@property (strong, nonatomic) UIImageView * bgImageView;
@property (nonatomic, strong) ZPScrollerScaleView *scrollerView;
@property (strong, nonatomic) UIButton * wechatBtn;
@property (strong, nonatomic) UILabel * wechatLabel;
@property (strong, nonatomic) UIButton * qqBtn;
@property (strong, nonatomic) UILabel * qqLabel;
@end

@implementation ShareViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"邀请好友";
    [self.view addSubview:self.bgImageView];
    [self.view addSubview:self.scrollerView];
    [self.view addSubview:self.wechatBtn];
    [self.view addSubview:self.wechatLabel];
    [self.view addSubview:self.qqBtn];
    [self.view addSubview:self.qqLabel];

    //1:创建子视图 并添加到数组中
    NSMutableArray * items = [NSMutableArray array];
    for(NSInteger i =0; i < 10; i++){
        CardView * view = [[CardView alloc] init];
        view.codeLabel.text = [NSString stringWithFormat:@"%zd验证码",i];
        [items addObject:view];
    }
    //至少要是等于 2-8
    //self.scrollerView.defalutIndex = 9;
    self.scrollerView.items = items;
}


- (void)wechatBtnClick:(UIButton *)sender{
    NSLog(@"wechat");
}

- (void)qqBtnClick:(UIButton *)sender{
    NSLog(@"qq");
}

-(UIImageView *)bgImageView{
    if (!_bgImageView) {
        _bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"share_bg_image"]];
        _bgImageView.frame = CGRectMake(0, kNavBarAndStatusBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-kNavBarAndStatusBarHeight);
    }
    return _bgImageView;
}


- (ZPScrollerScaleView *)scrollerView
{
    if (!_scrollerView) {
        ZPScrollerScaleViewConfig * config = [[ZPScrollerScaleViewConfig alloc]init];
        config.scaleMin = 0.9;
        config.scaleMax = 1;
        config.pageSize = CGSizeMake(SCREEN_WIDTH - 100, 600);
        config.ItemMaingin = 5;
        /**初始化滚动缩放视图*/
        _scrollerView = [[ZPScrollerScaleView alloc] initWithConfig:config];
        CGFloat scale = 0.7;
        if (kIs_iPhoneX) {
            scale = 0.8;
        }
        _scrollerView.frame = CGRectMake(0, kNavBarAndStatusBarHeight+AD(20), SCREEN_WIDTH, SCREEN_HEIGHT * scale);
    }
    return _scrollerView;
}

-(UIButton *)wechatBtn{
    if (!_wechatBtn) {
        _wechatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_wechatBtn setBackgroundImage:[UIImage imageNamed:@"icon_wechat"] forState:UIControlStateNormal];
        _wechatBtn.frame = CGRectMake(0, SCREEN_HEIGHT-AD(90), AD(60), AD(60));
        _wechatBtn.centerX = SCREEN_WIDTH/4;
        [_wechatBtn addTarget:self action:@selector(wechatBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _wechatBtn;
}
-(UILabel *)wechatLabel{
    if (!_wechatLabel) {
        _wechatLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _wechatBtn.bottom + AD(5), AD(100), AD(25))];
        _wechatLabel.textAlignment = NSTextAlignmentCenter;
        _wechatLabel.text = @"微信";
        _wechatLabel.font = [UIFont systemFontOfSize:AD(16)];
        _wechatLabel.centerX = self.wechatBtn.centerX;
        _wechatLabel.textColor = [UIColor whiteColor];
    }
    return _wechatLabel;
}

-(UIButton *)qqBtn{
    if (!_qqBtn) {
        _qqBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_qqBtn addTarget:self action:@selector(qqBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_qqBtn setBackgroundImage:[UIImage imageNamed:@"icon_qq"] forState:UIControlStateNormal];
        _qqBtn.frame = CGRectMake(0, SCREEN_HEIGHT-AD(90), AD(60), AD(60));
        _qqBtn.centerX = SCREEN_WIDTH*3/4;
    }
    return _qqBtn;
}
-(UILabel *)qqLabel{
    if (!_qqLabel) {
        _qqLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, _wechatBtn.bottom + AD(5), AD(100), AD(25))];
        _qqLabel.textAlignment = NSTextAlignmentCenter;
        _qqLabel.text = @"QQ";
        _qqLabel.font = [UIFont systemFontOfSize:AD(16)];
        _qqLabel.centerX = self.qqBtn.centerX;
        _qqLabel.textColor = [UIColor whiteColor];
    }
    return _qqLabel;
}

@end
